﻿<div id="list" />
@section footer{
<script src="@Url.Content("~/Scripts/jquery/jquery.validate.js")" type="text/javascript"></script>
	<script type="text/javascript">
	    var columns = [
			  { display: '工种编号', name: 'Id', align: 'left', width: 80, minWidth: 60 }
			, { display: '工种名称', name: 'Name', align: 'left', width: 180, minWidth: 60 }
			, { display: '备注', name: 'Remark', align: 'left', width: 200, minWidth: 60 }
		];

	    var toolbaritems = [
              { id: "C", text: '添加', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/add.png")' }
            , { line: true }
            , { id: "U", text: '修改', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/edit.png")' }
            , { line: true }
            , { id: "D", text: '删除', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/delete.png")' }
        ];

	    function toolbarclick(item) {
	        var width = 800;
	        var height = 400;
	        switch (item.id) {
	            case "C":
	                child = $.ligerDialog.open({ width: width, height: height, url: '@Url.Action("Create")', showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '工种新增' });
	                break;
	            case "U":
	                var rows = grid.getSelected();
	                if (!rows) { $.ligerDialog.warn('请选择行!'); return }
	                child = $.ligerDialog.open({ width: width, height: height, url: '@Url.Action("Update")' + '?keys=' + rows.Id.toString(), showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '工种更新' });
	                break;
	            case "D":
	                var rows = grid.getSelecteds();
	                if (rows.length == 0) { $.ligerDialog.warn('请选择行!'); return }
	                $.ligerDialog.confirm("确认删除吗", function (r) {
	                    if (r) {
	                        LG.gridpost('@Url.Action("Delete")', { data: JSON.stringify(rows) }, grid);
	                    }
	                });
	                break;
	        }
	    }

	    $(function () {
	        grid = $("#list").ligerGrid({
	            url: '@Url.Action("GetGrid")', columns: columns, dataAction: 'server', pageSize: 20, sortName: 'Id', sortOrder: 'asc',
	            rownumbers: true, width: '98%', height: '100%', heightDiff: -10, checkbox: false, toolbar: {}
	        });
	        if (grid.toolbarManager) {
	            grid.toolbarManager.set("items", toolbaritems);
	        }
	    });
	</script>

}

